package com.example.xlzx.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.example.xlzx.entity.Post;
import com.example.xlzx.entity.PostReply;
import com.example.xlzx.dao.PostReplyMapper;
import com.example.xlzx.service.IPostReplyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 帖子回复表 服务实现类
 * </p>
 *
 * @author 1
 * @since 2025-03-07
 */
@Service
public class PostReplyServiceImpl extends ServiceImpl<PostReplyMapper, PostReply> implements IPostReplyService {

    @Override
    public Boolean updatePostReplyInfo(PostReply postReply) {
        return lambdaUpdate()
                .eq(PostReply::getId,postReply.getId())
                .set(StringUtils.isNotEmpty(postReply.getContent()),PostReply::getContent,postReply.getContent())
                .update();
    }

    @Override
    public List<PostReply> getPostReplyList(Long postId) {
        return lambdaQuery()
                .eq(PostReply::getPostId,postId)
                .list();
    }
}
